package grav;

import static mathUtils.VecMath.*;

import java.util.*;

import forces.FieldForce;

public class Gravity implements FieldForce{

	public float constant = 1.0f;
	public ArrayList<Gravitational> objectList;

	public Gravity() {
		objectList = new ArrayList<Gravitational>();
	}
	
	public void applyForces() {
		float f[] = vecCloneSpace(objectList.get(0).position());
		for (int i = 0; i < objectList.size(); ++i) {
			Gravitational a = objectList.get(i);
			for (int j = i+1; j < objectList.size(); ++j) {
				Gravitational b = objectList.get(j);
				f = b.geeForceOn(a, constant);
				a.takeForce(f);
				vecScale(f, -1);
				b.takeForce(f);
			}
		}
	}
	
}
